package com.ht.module.bus.controller;

import com.ht.module.bus.vo.StationToNumberVo;
import com.ht.util.JsonResult;
import com.ht.util.Pager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ht.module.bus.entity.TSchool;
import com.ht.module.bus.service.TSchoolService;
import com.ht.util.*;

import javax.validation.Valid;


/**
 * <p>
 * 学校信息表 前端控制器
 * </p>
 *
 * @author hejialun
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/t-school")
public class TSchoolController {


    @Autowired
    private TSchoolService tSchoolService;


    @ApiOperation("学校年级班级树接口")
    @GetMapping("/findSchoolClassTree")
    public JsonResult findSchoolClassTree() {
        return JsonResult.success(tSchoolService.findSchoolClassTree());
    }


    @ApiOperation("区划学校班级树接口")
    @GetMapping("/findDistrictSchoolClassTree")
    public JsonResult findDistrictSchoolClassTree() {
        return JsonResult.success(tSchoolService.findDistrictSchoolClassTree());
    }


    @ApiOperation("学校站点学生乘车人数分析")
    @GetMapping("/findStationToNumber")
    public JsonResult findStationToNumber(Pager<StationToNumberVo> pager, TSchool en) {
        return JsonResult.success(tSchoolService.findStationToNumber(pager,en));
    }



    @ApiOperation("学校出现需求查询")
    @GetMapping("/findTripList")
    public JsonResult findTripList(TSchool en) {
        return JsonResult.success(tSchoolService.findTripList(en));
    }


    @ApiOperation("列表查询")
    @GetMapping("/findList")
    public JsonResult findList(TSchool en) {
        return JsonResult.success(tSchoolService.findList(en));
    }


    @ApiOperation("分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<TSchool> pager, TSchool en) {
        return JsonResult.success(tSchoolService.findPage(pager, en));
    }



    @ApiOperation("带权限分页查询")
    @GetMapping("/findPageAuth")
    public JsonResult findPageAuth(Pager<TSchool> pager, TSchool en) {
        return JsonResult.success(tSchoolService.findPageAuth(pager, en));
    }

    @ApiOperation("带权限列表查询")
    @GetMapping("/findListAuth")
    public JsonResult findListAuth(TSchool en) {
        return JsonResult.success(tSchoolService.findListAuth(en));
    }



    @ApiOperation("通过id查询")
    @GetMapping("/get-by-id/{id}")
    public JsonResult getById(@PathVariable(value = "id") String id) {
        return JsonResult.success(tSchoolService.getById(id));
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public JsonResult add(@RequestBody @Valid TSchool en) {
        CommMethod.beanCreate(en);
        tSchoolService.add(en);
        return JsonResult.success();
    }

    @ApiOperation("通过id删除")
    @DeleteMapping("/delete-by-id/{id}")
    public JsonResult delete(@PathVariable(value = "id") String id) {
        tSchoolService.removeById(id);
        return JsonResult.success();
    }

    @ApiOperation("修改")
    @PutMapping("/update")
    public JsonResult updateById(@RequestBody @Valid TSchool en) {
        CommMethod.beanUpdate(en);
        tSchoolService.updateById(en);
        return JsonResult.success();
    }

}
